<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>通知管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$(".a-model").click(function(){
				thiz = this;
				$("#view_notify_modal").on('show', function () {
					$(".modal-body").load(thiz.href);
				});
				$("#view_notify_modal").modal('show');
				var readFlag = $(this).data("flag");
				if(readFlag == '0') {
					unReadNum();
					$('#view_notify_modal').on('hide', function () {
						$(".modal-body").empty();
						window.location.href = "${ctx}/office/notify/officeNotifyRecord";
					});
				} else {
					$("#view_notify_modal").on('hide', function () {
						$(".modal-body").empty();
					});
				}
				return false;
			});
		});
		//标记已读时重置未读数量
		function unReadNum () {
			var count = parseInt(top.$("#notifyNum").html());//未读的个数
			count--;
			top.$("#notifyNum").html(count);
			top.$("#notifyNum2").html(count);
			if(count == 0){ 
				top.$("#notifyNum").hide();
				top.$("#notifyNum2").hide();
			}
		}
		function page(n,s){
			loading('正在查询，请稍等...');
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/office/notify/officeNotifyRecord/">通知列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="officeNotifyRecord" action="${ctx}/office/notify/officeNotifyRecord/" method="post">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>序号</th>
				<th>类型</th>
				<th>标题</th>
				<th>发布日期</th>
				<th>状态</th>
				<shiro:hasPermission name="office:officeNotifyRecord:view"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="officeNotifyRecord" varStatus="vs">
			<tr class="class">
				<td>
					${vs.index + 1 }
				</td>
				<td>
					${fns:getDictLabel(officeNotifyRecord.officeNotify.type, "OFFICE_NOTIFY_TYPE", "未知")}
				</td>
				<td>
					<a href="${ctx}/office/notify/officeNotifyRecord/view?id=${officeNotifyRecord.id}" data-flag="${officeNotifyRecord.readFlag}" class="a-model">
						<c:choose>
							<c:when test="${officeNotifyRecord.readFlag eq '0' }">
								<strong>${fns:abbr(officeNotifyRecord.officeNotify.title,20)}</strong>
							</c:when>
							<c:otherwise>
								${fns:abbr(officeNotifyRecord.officeNotify.title,20)}
							</c:otherwise>
						</c:choose>
					</a>
				</td>
				<td>
					<fmt:formatDate value="${officeNotifyRecord.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${fns:getDictLabel(officeNotifyRecord.readFlag, "READ_FLAG", "未知")}
				</td>
				<shiro:hasPermission name="office:officeNotifyRecord:view">
				<td>
					<a href="${ctx}/office/notify/officeNotifyRecord/view?id=${officeNotifyRecord.id}" data-flag="${officeNotifyRecord.readFlag}" class="a-model">查看</a>
					<c:if test="${officeNotifyRecord.readFlag eq '0' }">
						<a onclick="unReadNum();" href="${ctx}/office/notify/officeNotifyRecord/read?id=${officeNotifyRecord.id}">已读</a>
					</c:if>
				</td>
				</shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	<div id="view_notify_modal" class="modal hide fade"  tabindex="-1" role="dialog" aria-labelledby="viewNotifyModalLabel" aria-hidden="true">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h5 id="viewNotifyModalLabel">通知详情</h5>
		</div>
		<div class="modal-body">
		</div>
		<div class="modal-footer">
    		<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">确定</button>
  		</div>
	</div>
</body>
</html>